home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / AppMaker 2.0b3 / Demo AppMaker 2.0b3 / Examples / pre-built AMReminder / Procedural / Add.c next >
Encoding:
C/C++ Source or Header  |  1995-10-05  |  3.4 KB  |  143 lines  |  [TEXT/MMCC]

  1. /* Add.c -- Modal dialog */
  2. /* Created 01/01/95 12:01 PM by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <TextEdit.h>
  12. #include "ResourceDefs.h"
  13. #include "Miscellany.h"
  14. #include "DialogAids.h"
  15. #include "WindowAids.h"
  16. #include "Add.h"
  17.  
  18. #define OKButton        1
  19. #define CancelButton        2
  20. #define LogoPicture        3
  21. #define AddReminderForLabel        4
  22. #define DateLabel        5
  23. #define DateField        6
  24. #define TimeLabel        7
  25. #define TimeField        8
  26. #define AMRadio        9
  27. #define PMRadio        10
  28. #define MessageLabel        11
  29. #define MessageField        12
  30. #define WhenRemindingLabel        13
  31. #define DisplayIconCheck        14
  32. #define DisplayAlertCheck        15
  33. #define PlaySoundCheck        16
  34. #define SoundLabel        17
  35. #define SoundPopup        18
  36.  
  37. static void DoLogoPicture (void);
  38. static pascal void DrawSoundPopup    (DialogPtr        whichDialog,
  39.                                      short            itemNr);
  40.  
  41. /*----------*/
  42. static void DoLogoPicture ()
  43. {
  44. } /*DoLogoPicture*/
  45.  
  46. /*----------*/
  47. static pascal void DrawSoundPopup    (DialogPtr        whichDialog,
  48.                                      short            itemNr)
  49. {
  50.     AddRecPtr    data;
  51.  
  52.     data = (AddRecPtr) GetWRefCon (whichDialog);
  53.     DrawPopup (itemNr, MENU_Sound, data->SoundChoice);
  54. } /*DrawSoundPopup*/
  55.  
  56. /*----------*/
  57. Boolean GetAdd (AddRec    *Add)
  58. {
  59.     DialogPtr        theDialog;
  60.     GrafPtr            savePort;
  61.     Boolean            result;
  62.     Boolean            done;
  63.     short            itemNr;
  64.     register AddRecPtr    info;
  65.     ModalFilterUPP    FilterAddUPP;
  66.     UserItemUPP        DrawSoundPopupUPP;
  67.  
  68.     GetPort (&savePort);
  69.     InitCursor ();
  70.     theDialog = GetNewDialog (DLOG_Add, nil, (WindowPtr) -1L);
  71.     SetWRefCon (theDialog, (long) Add);
  72.     SetPort (theDialog);
  73.     info = Add;
  74.     SetDText (DateField, info->DateText);
  75.     SetDText (TimeField, info->TimeText);
  76.     SetRadio (AMRadio, info->AmPmChoice);
  77.     SetDText (MessageField, info->MessageText);
  78.     SetCheckbox (DisplayIconCheck, info->DisplayIconChecked);
  79.     SetCheckbox (DisplayAlertCheck, info->DisplayAlertChecked);
  80.     SetCheckbox (PlaySoundCheck, info->PlaySoundChecked);
  81.     DrawSoundPopupUPP = NewUserItemProc (DrawSoundPopup);
  82.     SetUserItem (SoundPopup, DrawSoundPopupUPP);
  83.     FilterAddUPP = NewModalFilterProc (StandardFilter);
  84.  
  85.     ShowWindow (theDialog);
  86.     OutlineButton (1);
  87.     done = false;
  88.     while (!done) {
  89.  
  90.         MovableDialog (FilterAddUPP, &itemNr);
  91.         switch (itemNr) {
  92.             case OKButton:
  93.                     result = true;
  94.                     done = true;
  95.                 break;
  96.             case CancelButton:
  97.                     result = false;
  98.                     done = true;
  99.                 break;
  100.             case LogoPicture:
  101.                     DoLogoPicture ();
  102.                 break;
  103.             case DateField:
  104.                     GetDText (itemNr, info->DateText);
  105.                 break;
  106.             case TimeField:
  107.                     GetDText (itemNr, info->TimeText);
  108.                 break;
  109.             case AMRadio:
  110.             case PMRadio:
  111.                     DoRadio (AMRadio, itemNr, &info->AmPmChoice);
  112.                 break;
  113.             case MessageField:
  114.                     GetDText (itemNr, info->MessageText);
  115.                 break;
  116.             case DisplayIconCheck:
  117.                     DoCheckbox (itemNr, &info->DisplayIconChecked);
  118.                 break;
  119.             case DisplayAlertCheck:
  120.                     DoCheckbox (itemNr, &info->DisplayAlertChecked);
  121.                 break;
  122.             case PlaySoundCheck:
  123.                     DoCheckbox (itemNr, &info->PlaySoundChecked);
  124.                 break;
  125.             case SoundPopup:
  126.                     InvertLabel (SoundLabel);
  127.                     DoPopup (SoundPopup, MENU_Sound, &info->SoundChoice);
  128.                     InvertLabel (SoundLabel);
  129.                     PlaySound (MENU_Sound, info->SoundChoice);
  130.                 break;
  131.  
  132.         } /* switch */
  133.     } /* while */
  134.     DisposeRoutineDescriptor ((UniversalProcPtr) FilterAddUPP);
  135.     DisposeRoutineDescriptor ((UniversalProcPtr) DrawSoundPopupUPP);
  136.  
  137.     DisposDialog (theDialog);
  138.     SetPort (savePort);
  139.     return (result);
  140. } /*GetAdd*/
  141.  
  142. /* Add */
  143.